#ifndef OLLAMAAPI_H
#define OLLAMAAPI_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>

class OllamaAPI : public QObject
{
    Q_OBJECT
public:
    explicit OllamaAPI(QObject *parent = nullptr);
    
    void sendMessage(const QString &model, const QString &message);
    void setBaseUrl(const QString &url);
    void abortCurrentRequest();

signals:
    void responseStream(const QString &partialResponse);
    void responseFinished();
    void errorOccurred(const QString &error);

private slots:
    void onReplyFinished(QNetworkReply *reply);
    void onReadyRead();

private:
    QNetworkAccessManager *m_manager;
    QString m_baseUrl;
    QNetworkReply *m_currentReply;
    QString m_buffer;
};

#endif // OLLAMAAPI_H
